//
//  YiBaoViewController.m
//  ZIVSetView
//
//  Created by ziv on 16/9/9.
//  Copyright © 2016年 Ziv. All rights reserved.
//

#import "YiBaoViewController.h"

@interface YiBaoViewController ()<UIWebViewDelegate>

@property(weak,nonatomic)UIWebView *yv;

@property(weak,nonatomic) UIActivityIndicatorView *flowerView ;



@end

@implementation YiBaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"医保使用规则";
    
    [self loadData];
 
   
}
- (void)loadData
{
    
    UIWebView *yv = [[UIWebView alloc]initWithFrame:self.view.bounds];
    UIActivityIndicatorView *flowerView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray ];
    CGFloat x = [UIScreen mainScreen].bounds.size.width/2.0;
    CGFloat y = [UIScreen mainScreen].bounds.size.height/2.0;
   
    _yv = yv;
    yv.delegate = self;
    flowerView.center = CGPointMake(x, y);
    
    flowerView.bounds = CGRectMake(0, 0, 400, 400);
    [yv addSubview:flowerView];
    _flowerView = flowerView;
    
//    NSURL *URL = [NSURL URLWithString:@"hhttp://zhidao.baidu.com/link?url=8glGVHIORUlKA6GbPjWIvYr8JgKHa30R-1OJg1ulWKxw7P3BbnbW9xXZfwfK0gE9hFAbEuilszGSu0n-DLHUjAiE_37tlHvNWFygunTUv-i"];
    
    NSURL *URL = [NSURL URLWithString:@"www.baidu.com"];
    
    NSURLRequest *requestM = [NSURLRequest requestWithURL:URL];
    [yv loadRequest:requestM];
    yv.scalesPageToFit =YES;
    [self.view addSubview:yv];



}

-(void)webViewDidStartLoad:(UIWebView *)webView
{
    [_flowerView startAnimating];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"网速不给力" preferredStyle:UIAlertControllerStyleAlert];
        //确定action
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"等待" style:UIAlertActionStyleDefault handler:nil];
        //取消
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"返回" style:UIAlertActionStyleCancel handler:nil];
        //添加action
        [alertController addAction:confirmAction];
        [alertController addAction:cancelAction];
        //显示
        [self presentViewController:alertController animated:YES completion:nil];
        
    });



}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
